find the kth smallest element in an array